package com.toe.admin.controller;

import com.toe.business.service.BusinessInformationService;
import com.toe.commodity.service.CommodityClassesService;
import com.toe.commodity.service.CommodityGoodsService;
import com.toe.commodity.service.CommodityPictureService;
import com.toe.common.restful.JsonResult;
import com.toe.pojo.dto.business.BusinessInfoUpdateDTO;
import com.toe.pojo.entity.commodity.CommodityClasses;
import com.toe.pojo.vo.business.BusinessInfoDetailsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("businessBackAdmin")
@Api(tags = "商家后台管理系统")
public class BusinessBackgroundController {
    @DubboReference
    private BusinessInformationService dubboBusinessInformationService;

    @DubboReference
    private CommodityClassesService commodityClassesService;

    @DubboReference
    private CommodityGoodsService commodityGoodsService;

    @DubboReference
    private CommodityPictureService commodityPictureService;

    @ApiOperation(value = "修改商家信息")
    @PostMapping("/update")
    public JsonResult<Void> updateBusinessInfo(@RequestBody BusinessInfoUpdateDTO businessInfoUpdateDTO) {
        dubboBusinessInformationService.updateBusinessInfo(businessInfoUpdateDTO);
        return JsonResult.ok();
    }

    @PostMapping("/show/business/{id}")
    @ApiOperation("显示商家详细信息")
    public JsonResult<BusinessInfoDetailsVO> queryBusinessById(@PathVariable Long id) {
        BusinessInfoDetailsVO businessInfoDetailsVO = dubboBusinessInformationService.businessInfoDetails(id);
        return JsonResult.ok(businessInfoDetailsVO);
    }

}
